<?php

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Content-type: text/html; charset=utf-8');

require_once 'database.php';

$db = CE_Database::getInstance();

$sql = 'SELECT facebook_id, name, latitude, longitude, quest_state, score ';
$sql .= ' FROM disrupt ';
$sql .= ' ORDER BY score DESC ';
$players = $db->getObjectArray($sql);

?>
<!DOCTYPE html>
<html>
<head>
<title>Arena Blitz</title>
</head>
<body onload="window.setTimeout('location.reload()', 5000)">
<table border="1" cellspacing="4" cellpadding="4">
<tr>
<th></th>
<th>Player</th>
<th>Location</th>
<th>Quest</th>
<th>Score</th>
</tr>
<?php foreach ($players as $player) { ?>
<tr>
<td><img id="image" src="https://graph.facebook.com/<?= $player->facebook_id ?>/picture" width="48" height="48"/></td>
<td><?= htmlentities($player->name) ?></td>
<td><?= number_format($player->latitude, 6) ?>, <?= number_format($player->longitude, 6) ?></td>
<td align="center"><?= intval($player->quest_state + 1) ?></td>
<td align="center"><?= intval($player->score) ?></td>
</tr>
<?php } ?>
</table>
</body>
</html>
